#include "log/log.h"
#include <pthread.h>
#include "app_common.h"

int cnt = 0;
pthread_mutex_t mutext = PTHREAD_MUTEX_INITIALIZER;
void *first_thread_func(void *arg)
{
    
    for (size_t i = 0; i < 1145; i++)
    {
        pthread_mutex_lock(&mutext);
        cnt++;
        pthread_mutex_unlock(&mutext);

    }
    log_info("cnt = %d",cnt);
    
}

int main(int argc, char const *argv[])
{
    pthread_t ptArr[10];
    for (size_t i = 0; i < 10; i++)
    {
        if (pthread_create(&ptArr[i], NULL, first_thread_func, NULL) != 0)
        {
            log_error("线程创建失败");

            return;
        }
        log_info("ptArr[%d]线程创建成功",i);
    }

    for (size_t i = 0; i < 10; i++)
    {
        pthread_join(ptArr[i], NULL);
    }            
    log_info("进程结束");

    return 0;
}